'''
鼠标事件
（1）perform()  执行所有ActionChains中存储的行为
move_to_element()  鼠标悬停
drag_and_drop(source.target)  鼠标拖动
key_down() 键按下
key_up()  键抬起

'''

from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
#导入鼠标事件的类


chrome_location = r'E:\nmon\light_Chrome\chrome-win\chrome.exe'
options = webdriver.ChromeOptions()
options.binary_location = chrome_location

driver = webdriver.Chrome(options=options)
driver.get(r'https://www.baidu.com')
sleep(2)

# #左键双击double_click()
# driver.find_element(By.ID,'kw').send_keys('aaaa')
# ele = driver.find_element(By.ID,'kw')
# ActionChains(driver).double_click(ele).perform()
# sleep(3)

# #右键单击context_click
#
# ele = driver.find_element(By.ID,'kw')
# ActionChains(driver).context_click(ele).perform()
# sleep(3)

# #鼠标悬停
# ele = driver.find_element(By.XPATH,'/html/body/div[2]/div[1]/div[3]/div/a')
# ActionChains(driver).move_to_element(ele).perform()
# sleep(3)

#鼠标拖动
ele1 = driver.find_element(By.CLASS_NAME,'title-content-title')

ele2 = driver.find_element(By.ID,'kw')
ActionChains(driver).drag_and_drop(ele1,ele2).perform()
sleep(4)




